"""
商品分类浏览 用例
"""
import unittest
from common.Base import open_browser
from Page.home_page import home_url, Home_page


class CategoryCase(unittest.TestCase):

    def setUp(self):
        # 打开浏览器
        self.driver = open_browser()
        self.lp = Home_page(self.driver)
        # 打开首页页面
        self.lp.open_url(home_url)

    def tearDown(self):
        # 关闭浏览器
        self.lp.quit()

    # 首页
    def test_category_001(self):
        self.lp.click_SY()
        self.assertIn("ECSHOP演示站", self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 家用电器
    def test_category_002(self):
        self.lp.click_JYDQ()
        a = self.lp.get_element_text(self.lp.jydq_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录大家电
    def test_category_003(self):
        self.lp.click_DJD()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 数码时尚
    def test_category_004(self):
        self.lp.click_SMSS()
        a = self.lp.get_element_text(self.lp.smss_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 智能硬件
    def test_category_005(self):
        self.lp.click_ZNYJ()
        a = self.lp.get_element_text(self.lp.znyj_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 移动电源
    def test_category_006(self):
        self.lp.click_YDDY()
        a = self.lp.get_element_text(self.lp.yddy_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 手机类型
    def test_category_007(self):
        self.lp.click_SJLX()
        a = self.lp.get_element_text(self.lp.sjlx_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录小型手机
    def test_category_008(self):
        self.lp.click_XSSJ()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录3G手机
    def test_category_009(self):
        self.lp.click_SGSJ()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 手机
    def test_category_010(self):
        self.lp.click_SJ()
        a = self.lp.get_element_text(self.lp.sj_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录耳机
    def test_category_011(self):
        self.lp.click_EJ()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录电池
    def test_category_012(self):
        self.lp.click_DC()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 充值卡
    def test_category_013(self):
        self.lp.click_CZK()
        a = self.lp.get_element_text(self.lp.czk_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 服装
    def test_category_014(self):
        self.lp.click_FZ()
        a = self.lp.get_element_text(self.lp.fz_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 配件
    def test_category_015(self):
        self.lp.click_PJ()
        a = self.lp.get_element_text(self.lp.pj_location)
        self.assertIn(a, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录数码时尚
    def test_category_016(self):
        self.lp.click_ZSMSS()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())

    # 子目录保护壳
    def test_category_017(self):
        self.lp.click_BHK()
        self.assertIn(self.lp.text, self.lp.title(), msg="用例失败")
        print(self.lp.title())


if __name__ == '__main__':
    unittest.main()
